﻿using Coldairarrow.Entity.Base_Manage;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Coldairarrow.Util.ClassLibrary;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Business.PB
{
    public partial interface IPB_PackListBusiness
    {
        Task<PageResult<PB_PackList>> GetDataListAsync(PageInput<ConditionDTO> input);
        Task<PB_PackList> GetTheDataAsync(string id);
        Task AddDataAsync(PB_PackList data);
        /// <summary>
        /// 批量生成箱码
        /// </summary>
        /// <param name="nums"></param>
        /// <param name="_mongodbOptions"></param>
        /// <returns></returns>
        Task AddrowsAsyne(Print data, MongoDBOptions _mongodbOptions);
        Task UpdateDataAsync(PB_PackList data);
        Task DeleteDataAsync(List<string> ids);

        /// <summary>
        /// 通知入库
        /// </summary>
        /// <param name="query">请求参数</param>
        /// <returns></returns>
        Task NoticeWarehousing(NoticeWarehousingQuery query);
        /// <summary>
        /// PC包列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<PB_PackListDTO>> GetDataListPackDto(PageInput<PackListConditionDTO> input);//查询包
        Task<PageResult<PB_PackListDTO>> GetDataListPackDtoXiang(PageInput<PackListConditionDTO> input);//查询箱
        Task<List<PB_PackListDTO>> Selectid(string id);
        Task<List<PB_PackListDTO>> Selectids(string ids);
        /// <summary>
        /// PC获取包的明细信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<PB_PackListDetailDTO>> GetPackListInfoListDataAsync(PageInput<PackListInfoConditionDTO> input);

        /// <summary>
        /// PC包明细成品码补打
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_mongodbOptions"></param>
        /// <returns></returns>
        Task PackInfoPrintAsync(PackInfoPrintData data, MongoDBOptions _mongodbOptions);

        /// <summary>
        /// 生成包编号
        /// </summary>
        /// <param name="userqrcode">操作人</param>
        /// <param name="PackageType">是否标准包</param>
        /// <param name="_mongodbOptions"></param>
        /// <returns></returns>
        Task<PB_PackList> GetPackListNumberAsync(string userqrcode, int PackageType, MongoDBOptions _mongodbOptions);

        /// <summary>
        /// 打包扫码添加打包明细(非混合包)(作废)
        /// </summary>
        /// <param name="qrcode">成品二维码</param>
        /// <param name="packId">包二维码</param>
        /// 优化打包逻辑   2022-03-02   赵锦涛
        /// <returns></returns>
        Task<PB_PackListDetailDTO> GetPackListDetailDataAsync(string qrcode, string packId);

        /// <summary>
        /// PDA扫描第一个成品码后修改包的信息
        /// </summary>
        /// <param name="qrcode">成品二维码</param>
        /// <param name="packId">包二维码</param>
        /// <param name="IsMax">大/小</param>
        /// PDA打包增加选择大小包 2022-02-24 赵锦涛
        /// <returns></returns> 
        Task UpdatePackListAsync(string qrcode, string packId, Boolean IsMax);

        /// <summary>
        /// 打包扫码添加打包明细(混合包)(作废)
        /// </summary>
        /// <param name="qrcode">成品二维码</param>
        /// <param name="packId">包二维码</param>
        /// <returns></returns>
        Task<PB_PackListDetailDTO> GetBlendPackListDetailDataAsync(string qrcode, string packId);

        /// <summary>
        /// PDA继续打包
        /// </summary>
        /// <param name="qrcode">成品二维码</param>
        /// <param name="packId">包二维码</param>
        /// <returns></returns>
        Task<PB_PackListDetailDTO> GetPackListDetailAsync(string qrcode, string packId);

        /// <summary>
        /// 获取包下的明细信息
        /// </summary>
        /// <param name="packId">包二维码</param>
        /// <returns></returns>
        Task<PB_PackListDataDTO> GetPackListDataAsync(string packId);
        Task<List<PB_PackListDTO>> GetPackListQrCode(string PackQrCode);
        /// <summary>
        /// 完成打包
        /// </summary>
        /// <param name="packId">包二维码</param>
        /// <param name="nums">数量</param>
        /// <returns></returns>
        Task<PB_PackListDTO> UpdatePackListDataAsync(string packId, int nums);

        /// <summary>
        /// 获取当前人的打包信息
        /// </summary>
        /// <param name="userqrcode">用户二维码</param>
        /// <param name="Type">包类型</param>
        /// <returns></returns>
        Task<List<PB_PackList>> GetPackListAsync(string userqrcode, int Type);

        /// <summary>
        /// 通知入库获取完成打包的数据
        /// </summary>
        /// <param name="userqrcode">用户二维码</param>
        /// 优化PDA通知入库列表   2022-03-02   赵锦涛
        /// <returns></returns>
        Task<List<PackListWarehousingNoticeDTO>> GetPackListWarehousDataAsync(string userqrcode);

        /// <summary>
        /// 扫描获取要通知入库的单个成品
        /// </summary>
        /// <param name="JobQrCode">成品二维码</param>
        /// <returns></returns>
        Task<PackListWarehousingNoticeDTO> GetJobMaterialDataAsync(string JobQrCode);

        Task<List<PB_PackList>> GetPackListWarehousDataManualInputAsync(string userqrcode);
        Task<List<PB_PackList>> GetPackListWarehousStatusAsync(string userqrcode);
        Task<List<PB_PackList>> GetPackListWarehousStatusManualInputAsync(string ManualInput);

        /// <summary>
        /// 删除打包明细信息
        /// </summary>
        /// <param name="packinfoId">打包明细Id</param>
        /// <returns></returns>
        Task DeletePackListInfoDataAsync(string packinfoId);

        /// <summary>
        /// 删除包信息
        /// </summary>
        /// <param name="packinfoId"></param>
        /// <returns></returns>
        Task DeletePackListDataAsync(string packinfoId);

        Task<PackListDetailDto> GetPackDetail(string QrCode);
        /// <summary>
        /// 拆包列表
        /// </summary>
        /// <returns></returns>
        Task<PageResult<PB_UnpackingDTO>> GetUnPackingListAsync(PageInput<ConditionDTO> input);

        /// <summary>
        /// 拆包明细
        /// </summary>
        /// <param name="ParentId">拆包主表id</param>
        /// <returns></returns>
        Task<List<PB_UnpackingDetailDTO>> GetUnPackingDetailListAsync(string ParentId);

        /// <summary>
        /// 批量生成包码
        /// </summary>
        /// <param name="data">数量</param>
        /// <param name="_mongodbOptions"></param>
        /// <returns></returns>
        Task AddBatchPackQrcodeAsync(Print data, MongoDBOptions _mongodbOptions);

        /// <summary>
        /// 批量重打包码
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task RetypeBatchPackQrcodeAsync(Print data, MongoDBOptions _mongodbOptions);

        /// <summary>
        /// 获取操作者法人下的所有仓库
        /// </summary>
        /// <returns></returns>
        Task<List<Base_Department>> GetDetpListAsync();

        /// <summary>
        /// PDA补打包码或者物料码
        /// </summary>
        /// <param name="code">包(物料)Id</param>
        /// <returns></returns>
        Task<PrintPackOrMaterialDTO> GetPrintPackOrMaterialDataAsync(string code);

        #region 初始化包数量

        Task SavePackMaterialListAsync();

        #endregion

        #region 盘点相关包、物料重置
        /// <summary>
        /// 重建包码
        /// </summary>
        /// <returns></returns>
        Task<PB_PackList> RebuildBagAsync(string strQrCode);

        /// <summary>
        /// 重建物料码
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PB_JobBookingQrCode> RebuildMaterialAsync(RebuildMaterialInputDTO input, RedisOptions _redisOptions);

        /// <summary>
        /// 重建包提交
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task RebuildSubmitAsync(RebuildSubmitInputDTO input);

        /// <summary>
        /// 物料重置获取物料信息
        /// </summary>
        /// <returns></returns>
        Task<JobBookMaterialDTO> GetJobBookMaterialDataAsync(RebuildMaterialInputDTO input);

        /// <summary>
        /// 生成物料码
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_redisOptions"></param>
        /// <param name="_mongodbOptions"></param>
        /// <returns></returns>
        Task SaveMaterialQrCodeAsync(MaterialQrCodeNewDTO data, RedisOptions _redisOptions, MongoDBOptions _mongodbOptions);

        #endregion

        #region  查询包信息或者物料信息

        /// <summary>
        /// 查询包信息或者物料信息
        /// </summary>
        /// <param name="QrCode">二维码</param>
        /// <returns></returns>
        Task<Object> GetPackOrMaterialDataAsync(string QrCode);

        #endregion

        Task<PageResult<ScanningCode>> GetscanningCodes(PageInput<IT_LocalDetailDtolistContionDTO> input, string PaickmainId);

    }

    public class PackListConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }
        public string WarehousStatus { get; set; }
    }

    public class PackListInfoConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }
        public string packId { get; set; }
    }
    public class Print
    {
        /// <summary>
        /// 打印数量
        /// </summary>
        public int? quantity { get; set; }

        /// <summary>
        /// 打印机id
        /// </summary>
        public string PrinterId { get; set; }

        /// <summary>
        /// 物料id
        /// </summary>
        public string MaterialId { get; set; }
        /// <summary>
        /// 打印包类型
        /// </summary>  0
        public int? PackageType { get; set; }
        /// <summary>
        /// 是否拆零
        /// </summary>  
        public Boolean? IsUnpacking { get; set; }
        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialIName { get; set; }
        /// <summary>
        /// 物料编号
        /// </summary>
        public String MaterCode { get; set; }
        /// <summary>
        /// 数量
        /// </summary>
        public Double? Nums { get; set; }

        public List<string> ids { get; set; }
    }

    public class PackInfoPrintData
    {
        public List<string> jobqrcodeIds { get; set; }

        public string PrinterId { get; set; }
    }

    /// <summary>
    /// PDA补打包码或者物料码
    /// </summary>
    public class PrintPackOrMaterialDTO
    {

        /// <summary>
        /// 组织名称
        /// </summary>
        public string DeptIdName { get; set; }

        /// <summary>
        /// 打码日期
        /// </summary>
        public string CreateTime { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public Double? Nums { get; set; }

        /// <summary>
        /// 二维码
        /// </summary>
        public string QrCode { get; set; }

        /// <summary>
        /// 包(物料)名称
        /// </summary>
        public string BoxName { get; set; }

        /// <summary>
        /// 规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        ///  编码
        /// </summary>
        public string Code { get; set; }

    }

    /// <summary>
    /// 通知入库生成收货单明细时使用
    /// </summary>
    public class JobMaterial
    {
        /// <summary>
        /// 成品Id
        /// </summary>
        public string JobBookingId { get; set; }

        /// <summary>
        /// 报工单Id
        /// </summary>
        public string JobId { get; set; }

        /// <summary>
        /// 数量
        /// </summary>

        public double? Nums { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 包Id
        /// </summary>
        public string PackId { get; set; }

        /// <summary>
        /// 单个物料入库Id
        /// </summary>
        public string JobMaterialId { get; set; }

    }

    #region 初始化包数量

    public class PackMaterialCount
    {
        /// <summary>
        /// 包Id
        /// </summary>
        public string PackId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public string Nums { get; set; }
    }

    #endregion

    #region  盘点相关包、物料重置

    /// <summary>
    /// 获取物料信息
    /// </summary>
    public class JobBookMaterialDTO
    {
        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 成品编码
        /// </summary>
        public string ProductCode { get; set; }

    }

    /// <summary>
    /// 生成物料码传值
    /// </summary>
    public class MaterialQrCodeNewDTO
    {
        /// <summary>
        /// 二维码
        /// </summary>
        public string QrCode { get; set; }

        /// <summary>
        /// 货位二维码
        /// </summary>
        public string LocaQrCode { get; set; }

        /// <summary>
        /// 物料信息
        /// </summary>
        public JobBookMaterialDTO JobMaterial { get; set; }

        /// <summary>
        /// 生成数量
        /// </summary>
        public double? Nums { get; set; }

        /// <summary>
        /// 打印机Id
        /// </summary>
        public string PrintId { get; set; }

    }

    #endregion


    #region  查询包信息或者物料信息DTO

    public class PackModelDTO
    {
        /// <summary>
        /// 1:包;2:物料;3:成品
        /// </summary>
        public int? Type { get; set; }

        /// <summary>
        /// 包Id
        /// </summary>
        public string PackId { get; set; }

        /// <summary>
        /// 包名称
        /// </summary>
        public string BoxName { get; set; }

        /// <summary>
        /// 包装数量
        /// </summary>
        public double? Nums { get; set; }

        /// <summary>
        /// 包类型
        /// </summary>
        public string PackTypeName { get; set; }

        /// <summary>
        /// 包状态
        /// </summary>
        public string Status { get; set; }

        /// <summary>
        /// 出库类型
        /// </summary>
        public string OutStock { get; set; }

        /// <summary>
        /// 包位置
        /// </summary>
        public string LocaName { get; set; }

        public List<MaterialLocaList> MaterialList { get; set; }

        /// <summary>
        /// 项目
        /// </summary>
        public string ProjectName { get; set; }

        public PrintPackOrMaterialDTO PackOrMaterial { get; set; }

    }

    public class MaterialLocaList
    {
        /// <summary>
        /// 位置
        /// </summary>
        public string StorAreaName { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public double? Nums { get; set; }

    }

    public class LocaMaterialListDTO
    {
        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 货位信息
        /// </summary>
        public string StorAreaName { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public double? Nums { get; set; }

    }


    #endregion
}